<!--
  ~
  ~ Copyright 2020 HuiFer All rights reserved.
  ~
  ~ Licensed under the Apache License, Version 2.0 (the "License");
  ~ you may not use this file except in compliance with the License.
  ~ You may obtain a copy of the License at
  ~
  ~      http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License.
  ~
  -->

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"
          name="viewport">
    <meta content="ie=edge" http-equiv="X-UA-Compatible">
    <title>login</title>

    <link href="https://unpkg.com/element-ui/lib/theme-chalk/index.css" rel="stylesheet">
    <script src="https://unpkg.com/element-ui/lib/index.js"></script>
</head>
<body>
<div id="app">

    <el-input placeholder="请输入内容" v-model="login.username"></el-input>
    <el-input placeholder="请输入内容" v-model="login.password"></el-input>
    <el-button @click="loginApi" type="primary">login</el-button>
</div>
</body>


<script src="https://unpkg.com/vue/dist/vue.js"></script>
<!-- import JavaScript -->
<script src="https://unpkg.com/element-ui/lib/index.js"></script>

<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<script>
    new Vue({
        el: '#app',
        data: function () {
            return {
                login: {
                    username: "",
                    password: ""
                }
            }
        },
        methods: {
            loginApi() {
                axios.get("/redis/login", {
                    params: {
                        'login_name': this.login.username,
                        'password': this.login.password
                    }
                }).then(resp => {
                    if (resp.data == "success") {
                        location.href = "/redis/index.html";
                    } else if (resp.data == "error") {
                        this.$message({
                            type: 'error',
                            message: "账号或者密码错误"
                        });
                    }
                    console.log(resp);
                }).catch(function (error) {
                    console.log(error);
                })
            }
        },

    })

</script>
</html>